import time
from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
cap_dict = {
    "deviceName":"127.0.0.1:62001",
    "platformName":"Android",
    "platformVersion":"7.1.2",
    "appPackage":"com.lingyue.zebraloan",
    "appActivity":"com.lingyue.banana.activities.BananaLaunchActivity"
}
driver = webdriver.Remote("http://localhost:4723/wd/hub",cap_dict)
"""
http: http协议
localhost：表示本机，当前电脑。等同于127.0.0.1
4723：端口号
/wd/hub：appium开启的地址
"""
# 设置隐式等待
driver.implicitly_wait(15)

# 点击弹窗中的同意按钮
time.sleep(2)
driver.find_element(MobileBy.ID,"com.lingyue.zebraloan:id/tv_confirm").click()

# 等待主页面加载
time.sleep(10)

# 点击用户故事
driver.find_elements(MobileBy.CLASS_NAME,"android.widget.ImageView")[5].click()
time.sleep(2)
# 断言页面是否正确
text = driver.find_element(MobileBy.ID,"com.lingyue.zebraloan:id/tv_title").text
assert text == "用户故事"







